# Maintainer: Alexey Pavlov <Alexpux@gmail.com>

_realname=ffms2
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=2.23.1
pkgrel=1
pkgdesc="A cross-platform wrapper library around libav/FFmpeg (mingw-w64)"
arch=('any')
url="https://github.com/FFMS/ffms2/"
license=('MIT')
options=('staticlibs' 'strip')
depends=("${MINGW_PACKAGE_PREFIX}-ffmpeg")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/FFMS/ffms2/archive/${pkgver%.*}.tar.gz")
sha256sums=('b09b2aa2b1c6f87f94a0a0dd8284b3c791cbe77f0f3df57af99ddebcd15273ed')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver%.*}"
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver%.*}/configure \
    --prefix=${MINGW_PREFIX} \
    --host=${MINGW_CHOST} \
    --build=${CARCH%%-*} \
    --disable-debug \
    --disable-static \
    --enable-shared
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="${pkgdir}" install

  install -Dm644 ${srcdir}/${_realname}-${pkgver%.*}/COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING
}
